<?php
/**
 * User: xahy
 * Description: 公共部分
 */
require __DIR__.'/vendor/autoload.php';

use Upyun\Upyun as UpYunObj;
use Upyun\Config as UpYunConfig;

/****
 * 链接又拍云服务
 * @param string $serverName 服务名称
 * @param string $serverUser 用户
 * @param string $serverPwd  密码
 */
$serverName = '';
$serverUser = '';
$serverPwd = '';
$serviceConfig = new UpYunConfig($serverName, $serverUser, $serverPwd);
$client = new UpYunObj($serviceConfig);









/***
 * User: xahy
 * Description: 将单位字节转换易懂的单位
 * @param $num
 * @return string
 */
function BytesTo($num){
    $p = 0;
    $format='bytes';
    if($num>0 && $num<1024){
        $p = 0;
        return number_format($num).' '.$format;
    }
    if($num>=1024 && $num<pow(1024, 2)){
        $p = 1;
        $format = 'KB';
    }
    if ($num>=pow(1024, 2) && $num<pow(1024, 3)) {
        $p = 2;
        $format = 'MB';
    }
    if ($num>=pow(1024, 3) && $num<pow(1024, 4)) {
        $p = 3;
        $format = 'GB';
    }
    if ($num>=pow(1024, 4) && $num<pow(1024, 5)) {
        $p = 3;
        $format = 'TB';
    }
    $num /= pow(1024, $p);
    return number_format($num, 3).' '.$format;
}


